<template>
  <view class="order_detail">
    <!-- #ifndef MP-WEIXIN -->
    <my-navbar
      leftText=""
      :title="orderInfo.order_sn"
      @leftClick="leftClick"
      leftIconColor="white"
      leftColor="white"
      url="https://copartner.oss-cn-beijing.aliyuncs.com/logo/2401/11/wgP26bV6qnoXRjGoHoVXvdy0W9OsiRMhJsb2ftw1.png"
    ></my-navbar>
    <!-- #endif -->
    <!-- 商品信息 -->
    <view class="p-t-10">
      <view class="recipe-goods">
        <view class="goods">
          <view class="tit">{{
            `${orderInfo.package_menu_name} (${orderInfo.date_range})`
          }}</view>
          <my-recipelist :list="orderInfo.package_menu_detail"></my-recipelist>
        </view>
        <view class="recipe-goods-total">
          <view class="allPrice"
            >商品总金额：
            <text class="price"
              ><text>￥</text>{{ orderInfo.order_amount }}</text
            >
          </view>
        </view>
      </view>
    </view>

    <view class="padding order_info">
      <view class="money bg-container">
        <view
          ><text>运费</text
          ><text class="gray_font">￥{{ orderInfo.delivery_fee }}</text></view
        >
        <view
          ><text>下单金额</text
          ><text class="gray_font">￥{{ orderInfo.should_money }}</text></view
        >
        <view
          ><text>差额</text
          ><text class="gray_font">￥{{ orderInfo.balance }}</text></view
        >
        <view
          ><text>实付金额</text
          ><text class="red_font">￥{{ orderInfo.real_money }}</text></view
        >
        <view
          ><text>支付方式</text
          ><text class="gray_font">{{ orderInfo.pay_method }}</text>
        </view>
        <view class="flex-btw bordertop bold fonts_30">
          <text>支付信息</text>
          <text>{{ orderInfo.pay_status }}</text>
        </view>
      </view>
      <view class="pay bg-container">
        <view
          ><text>下单时间</text><text style="color: gray">{{ orderInfo.created_at }}</text></view
        >
        <view
          ><text>订单编号</text><text>{{ orderInfo.order_sn }}</text></view
        >
        <view>
          <text>配送时间</text>
          <text>{{ orderInfo.send_time }}</text>
        </view>
        <view>
          <text class="prop">配送金额</text>
          <text>￥{{ orderInfo.send_money }}</text>
        </view>
        <view
          ><text class="prop">退货金额</text
          ><text>￥{{ orderInfo.return_money }}</text></view
        >
        <view style="margin-bottom: 20rpx"
          ><text class="prop">备注</text
          ><text>{{ orderInfo.remark }}</text></view
        >
      </view>

      <view v-if="settlement_info.length >= 1" class="money">
        <view class="flex-btw">
          <text class="title">结算记录</text>
        </view>
        <view v-for="settlement of settlement_info" :key="settlement.id">
          <text @click="toDetail(settlement.id)" class="line">{{
            settlement.order_sn
          }}</text>
          <text>￥{{ settlement.account_money }}</text>
        </view>
      </view>
      <view v-if="return_info.length >= 1" class="money">
        <view class="flex-btw">
          <text class="title">退货记录</text>
        </view>
        <view v-for="returns of return_info" :key="returns.id">
          <text @click="returninfo(returns.id)" class="line">{{
            returns.order_sn
          }}</text>
          <text>￥{{ returns.real_money }}</text>
        </view>
      </view>
      <view style="height: 20rpx"></view>
    </view>
  </view>
</template>

<script>
let app = getApp();
import { $https } from "@/static/js/request.js";
import MixinShowprice from "@/static/js/mixinshowprice.js";
export default {
  data() {
    return {
      logo: "",
      showLogo: 0,
      orderInfo: {}, //订单信息
      goodsList: [], //商品列表
      allList: [],
      startTime: "",
      endTime: "",
      return_info: [],
      settlement_info: [],
      type: 0,

      showAllData: false,
    };
  },
  mixins: [MixinShowprice],
  onReady() {
    getApp().setTitle();
  },
  onLoad(option) {
    this.getData(option.id);
    this.logo = uni.getStorageSync("logo");
    this.showLogo = uni.getStorageSync("showLogo");
  },
  methods: {
    getData(id) {
      $https(
        "GET",
        "menuOrderDetail",
        {
          id: id,
        },
        (res) => {
          const { data } = res.data;
          data.package_menu_detail = data.package_menu_detail.map((el) => ({
            lookDetail: false,
            ...el,
          }));
          this.orderInfo = data;
        }
      );
    },
    leftClick() {
      uni.navigateBack();
    },
    changeLookDetail(item) {
      //  查看详情
      this.$set(item, "lookDetail", !item.lookDetail);
    },
    changeAllData() {
      this.showAllData = !this.showAllData;
    },
  },
};
</script>

<style lang="scss" scoped>
.bg-container {
  padding: 0 25rpx;
  background-color: #ffffff;
  border-radius: 20rpx;
  margin-bottom: 20rpx;
}

.goods {
  color: #333;
  font-size: 28rpx;

  .tit {
    margin: 0 30rpx 20rpx;
    font-size: 30rpx;
    color: #000;
    font-weight: bold;
    margin-bottom: 20rpx;
    border-bottom: 1rpx solid #ececec;
    padding-bottom: 20rpx;
  }
}

.recipe-goods {
  width: calc(100% - 60rpx);
  margin: 0 auto 20rpx;
  padding-top: 30rpx;
  background-color: #ffffff;
  border-radius: 20rpx;
  .recipe-goods-total {
    text-align: right;
    padding: 30rpx 30rpx;
    box-sizing: border-box;
    font-family: PingFang SC;
    font-size: 30rpx;
    color: rgba(0, 0, 0, 0.85);
    .price {
      color: #f55726;
      font-size: 36rpx;
      text {
        color: #f55726;
        font-size: 22rpx;
      }
    }
  }
}

.order_info {
  .bordertop {
    border-top: 1rpx solid #ececec;
    padding: 20rpx 0;
  }
  .prop {
    white-space: nowrap;
    margin-right: 20rpx;
  }

  .pay > view,
  .money > view {
    margin-top: 20rpx;
  }

  .gray_font {
    color: gray;
  }
}

.order_detail {
  background-image: url("https://copartner.oss-cn-beijing.aliyuncs.com/logo/2401/10/QfgJI7gfEL8uIpGGtGNu0M1sU9c3FrFNethEEtUj.png");
  background-size: 750rpx 400rpx;
  background-position: 0 0;
  background-repeat: no-repeat;
  // #ifndef MP-WEIXIN
  background-position: 0 80rpx;
  // #endif
  // #ifdef APP-PLUS
  background-position: 0 calc(80rpx + var(--status-bar-height));
  // #endif
  .pay > view,
  .money > view {
    display: flex;
    justify-content: space-between;
  }

  .pay,
  .money {
    width: 690rpx;
    padding: 10rpx 30rpx;
  }

  .pay > view:nth-child(n + 2) text:last-child {
    color: gray;
  }

  .good_info {
    padding-top: 25rpx;
  }

  .title {
    font-size: 28rpx;
    font-weight: bold;
  }
}

.good_info {
  padding-bottom: 40rpx;

  .title {
    margin-bottom: 14rpx;
  }

  .sign_good {
    font-size: 24rpx;
    background: #fff;
    border-radius: 14rpx;
    padding: 20rpx;
    margin-top: 20rpx;

    + .sign_good {
      margin-top: 20rpx;
    }

    .yellow_tag {
      font-size: 20rpx;
      padding: 2rpx 12rpx;
      background: #ff9900;
      border-radius: 6rpx;
      color: #fff;
      margin-left: 8rpx;
    }

    .top {
      margin-bottom: 20rpx;

      .imgs {
        width: 120rpx;
        height: 120rpx;
        position: relative;

        .logo {
          width: 40rpx;
          height: 40rpx;
          position: absolute;
          top: 0;
          left: 0;
          z-index: 1;
        }

        .img {
          width: 120rpx;
          max-height: 100rpx;
          margin-right: 40rpx;
        }
      }

      .name {
        margin-left: 20rpx;
      }
    }

    .row {
      margin-bottom: 20rpx;

      text:first-child {
        display: inline-block;
        width: 60%;
      }
    }

    .note {
      color: #9a9a9a;
      white-space: normal;
      word-break: break-all;
    }

    .spu {
      margin-left: 20rpx;
      padding: 4rpx 8rpx;
      background: #f5f5f5;
      border-radius: 8rpx;
      font-size: 24rpx;
      transform: scale(0.8);
    }
  }
}

.line {
  color: #0f0acb;
  text-decoration: underline;
}

text {
  font-size: 26rpx;
  color: #333;
}

.p-t-10 {
  padding-top: 20rpx;
}
</style>
